feat: enhance ibc data - #31
Conversation
WalkthroughThe changes introduce explicit source and destination chain, port, and channel identifiers into the decoding and interface definitions for IBC fungible token and NFT messages. Methods for resolving chain IDs and node information are added to the API client, schemas are updated to support richer metadata, and tests and fixtures are revised to reflect the new data structures and API interactions. Changes
Sequence Diagram(s)sequenceDiagram
participant Test
participant Decoder
participant ApiClient
participant ChainRegistry
Test->>Decoder: decode(IBC message, apiClient)
Decoder->>ApiClient: getChainId()
ApiClient->>ApiClient: fetch /cosmos/base/tendermint/v1beta1/node_info
ApiClient-->>Decoder: chainId
alt Need counterparty chain ID
Decoder->>ApiClient: findIbcCounterPartyChainId(chainId, portId, channelId)
ApiClient->>ChainRegistry: ensure registries loaded
ChainRegistry-->>ApiClient: registry data
ApiClient-->>Decoder: counterpartyChainId or null
end
Decoder-->>Test: Decoded message with srcChainId, dstChainId, srcPort, dstPort, etc.
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
ac487ea to
bf3045f
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (2)
src/schema/rest.ts (1)
3-7: Consider allowing unknown keys to avoid brittle parsingThe
/node_inforesponse contains many additional fields (e.g.,protocol_version,liteserver_address, etc.).
If the API adds new keys later, strict validation will start failing. Appending.passthrough()(or.strict(false)) on the outer object keeps the schema future-proof while still validating the fields we care about.-export const zNodeInfo = z.object({ - default_node_info: z.object({ - network: z.string(), - }), -}); +export const zNodeInfo = z + .object({ + default_node_info: z + .object({ + network: z.string(), + }) + .passthrough(), + }) + .passthrough();src/api.ts (1)
63-88: Implement error handling and consider performance optimizations.The method logic correctly searches for IBC counterparty chains, but could benefit from enhanced error handling and performance considerations.
Consider adding error handling for the registry loading operation:
public async findIbcCounterPartyChainId( chainId: string, portId: string, channelId: string ): Promise<string | null> { + try { await this._getRegistries(); + } catch (error) { + console.error('Failed to load registries:', error); + return null; + } const registry = this.registries.find( (registry) => registry.chain_id === chainId ); if (!registry) { return null; } const channel = registry.metadata.ibc_channels.find( (channel) => channel.port_id === portId && channel.channel_id === channelId ); if (!channel) { return null; } return channel.chain_id; }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Lite
📒 Files selected for processing (16)
src/api.ts(3 hunks)src/decoders/ibc/nft.ts(4 hunks)src/decoders/ibc/transfer.ts(3 hunks)src/interfaces/decoded-messages.ts(4 hunks)src/schema/index.ts(1 hunks)src/schema/registry.ts(1 hunks)src/schema/rest.ts(1 hunks)src/tests/fixtures/ibc/receive-ft.fixture.ts(1 hunks)src/tests/fixtures/ibc/receive-nft.fixture.ts(2 hunks)src/tests/fixtures/ibc/send-ft.fixture.ts(1 hunks)src/tests/fixtures/ibc/send-nft.fixture.ts(1 hunks)src/tests/fixtures/op-init/finalize-token-withdrawal.fixture.ts(1 hunks)src/tests/fixtures/op-init/initiate-token-deposit.fixture.ts(1 hunks)src/tests/ibc/receive-nft.test.ts(2 hunks)src/tests/ibc/send-nft.test.ts(3 hunks)src/tests/ibc/transfer.test.ts(4 hunks)
🧰 Additional context used
🧠 Learnings (17)
📓 Common learnings
Learnt from: ALPAC-4
PR: initia-labs/initia-registry#245
File: testnets/culinaris/chain.json:80-80
Timestamp: 2025-01-13T16:59:09.410Z
Learning: In chain.json files, the `op_bridge_id` field in the metadata section should be a string type, not an integer, as it represents the OPinit bridge identifier used for L1-L2 asset transfers.
Learnt from: joon9823
PR: initia-labs/initia.js#81
File: src/core/Msg.ts:518-521
Timestamp: 2024-10-08T18:48:55.677Z
Learning: In `src/core/Msg.ts`, within the `fromAmino` function, the type identifiers for `MsgUpdateIbcPermAdmin` and `MsgUpdatePermissionedRelayers` should use the prefix `'ibc-perm/'` as the valid identifier.
Learnt from: joon9823
PR: initia-labs/initia.js#81
File: src/core/Msg.ts:518-521
Timestamp: 2024-10-07T09:09:55.619Z
Learning: In `src/core/Msg.ts`, within the `fromAmino` function, the type identifiers for `MsgUpdateIbcPermAdmin` and `MsgUpdatePermissionedRelayers` should use the prefix `'ibc-perm/'` as the valid identifier.
Learnt from: ALPAC-4
PR: initia-labs/initia-registry#245
File: testnets/initia/chain.json:295-306
Timestamp: 2025-01-13T16:25:34.966Z
Learning: The correct chain ID for the Initia testnet is "initiation-2", not "initia-2". This is properly configured in both initia and culinaris chain configurations.
Learnt from: joon9823
PR: initia-labs/initia.js#81
File: src/core/marketmap/msgs/MsgUpsertMarkets.ts:33-33
Timestamp: 2024-10-07T09:11:45.236Z
Learning: In the `initia.js` codebase, the Amino message type identifiers use the `x` in the path as per the original protobuf definitions. For example, `'connect/x/marketmap/MsgUpsertMarkets'` is correct.
Learnt from: joon9823
PR: initia-labs/initia.js#81
File: src/core/marketmap/msgs/MsgUpsertMarkets.ts:33-33
Timestamp: 2024-10-10T16:15:27.381Z
Learning: In the `initia.js` codebase, the Amino message type identifiers use the `x` in the path as per the original protobuf definitions. For example, `'connect/x/marketmap/MsgUpsertMarkets'` is correct.
src/tests/fixtures/op-init/initiate-token-deposit.fixture.ts (5)
Learnt from: ALPAC-4
PR: initia-labs/initia-registry#245
File: testnets/culinaris/chain.json:80-80
Timestamp: 2025-01-13T16:59:09.410Z
Learning: In chain.json files, the `op_bridge_id` field in the metadata section should be a string type, not an integer, as it represents the OPinit bridge identifier used for L1-L2 asset transfers.
Learnt from: ALPAC-4
PR: initia-labs/initia-registry#245
File: testnets/initia/chain.json:295-306
Timestamp: 2025-01-13T16:25:34.966Z
Learning: The correct chain ID for the Initia testnet is "initiation-2", not "initia-2". This is properly configured in both initia and culinaris chain configurations.
Learnt from: joon9823
PR: initia-labs/initia.js#86
File: src/client/rest/api/IbcAPI.spec.ts:4-4
Timestamp: 2024-10-18T02:40:07.439Z
Learning: In `src/client/rest/api/IbcAPI.spec.ts`, the REST endpoint `https://rest.devnet.initia.xyz/` is acceptable even if it returns a 501 Not Implemented status code.
Learnt from: joon9823
PR: initia-labs/initia.js#81
File: src/core/Msg.ts:518-521
Timestamp: 2024-10-08T18:48:55.677Z
Learning: In `src/core/Msg.ts`, within the `fromAmino` function, the type identifiers for `MsgUpdateIbcPermAdmin` and `MsgUpdatePermissionedRelayers` should use the prefix `'ibc-perm/'` as the valid identifier.
Learnt from: joon9823
PR: initia-labs/initia.js#81
File: src/core/Msg.ts:518-521
Timestamp: 2024-10-07T09:09:55.619Z
Learning: In `src/core/Msg.ts`, within the `fromAmino` function, the type identifiers for `MsgUpdateIbcPermAdmin` and `MsgUpdatePermissionedRelayers` should use the prefix `'ibc-perm/'` as the valid identifier.
src/schema/index.ts (2)
Learnt from: ALPAC-4
PR: initia-labs/initia-registry#274
File: _packages/types/src/zods/Profile.ts:38-43
Timestamp: 2025-02-06T07:15:49.671Z
Learning: The TypeScript types and Zod schemas in `_packages/types/src/types/` and `_packages/types/src/zods/` are auto-generated from JSON Schema files in the root directory using json-schema-to-typescript and json-schema-to-zod libraries. Changes should be made to the source schema files, not the generated code.
Learnt from: ALPAC-4
PR: initia-labs/initia-registry#274
File: _packages/types/src/zods/Profile.ts:12-17
Timestamp: 2025-02-06T07:15:46.189Z
Learning: The TypeScript types and Zod schemas in `@initia/initia-registry-types` package are auto-generated from JSON Schema files in the root directory. Modifications should be made to the schema files rather than the generated code.
src/schema/rest.ts (2)
Learnt from: ALPAC-4
PR: initia-labs/initia-registry#274
File: _packages/types/src/zods/Profile.ts:38-43
Timestamp: 2025-02-06T07:15:49.671Z
Learning: The TypeScript types and Zod schemas in `_packages/types/src/types/` and `_packages/types/src/zods/` are auto-generated from JSON Schema files in the root directory using json-schema-to-typescript and json-schema-to-zod libraries. Changes should be made to the source schema files, not the generated code.
Learnt from: ALPAC-4
PR: initia-labs/initia-registry#274
File: _packages/types/src/zods/Profile.ts:12-17
Timestamp: 2025-02-06T07:15:46.189Z
Learning: The TypeScript types and Zod schemas in `@initia/initia-registry-types` package are auto-generated from JSON Schema files in the root directory. Modifications should be made to the schema files rather than the generated code.
src/tests/fixtures/op-init/finalize-token-withdrawal.fixture.ts (3)
Learnt from: joon9823
PR: initia-labs/initia.js#86
File: src/client/rest/api/IbcAPI.spec.ts:4-4
Timestamp: 2024-10-18T02:40:07.439Z
Learning: In `src/client/rest/api/IbcAPI.spec.ts`, the REST endpoint `https://rest.devnet.initia.xyz/` is acceptable even if it returns a 501 Not Implemented status code.
Learnt from: ALPAC-4
PR: initia-labs/initia-registry#245
File: testnets/culinaris/chain.json:80-80
Timestamp: 2025-01-13T16:59:09.410Z
Learning: In chain.json files, the `op_bridge_id` field in the metadata section should be a string type, not an integer, as it represents the OPinit bridge identifier used for L1-L2 asset transfers.
Learnt from: ALPAC-4
PR: initia-labs/initia-registry#245
File: testnets/initia/chain.json:295-306
Timestamp: 2025-01-13T16:25:34.966Z
Learning: The correct chain ID for the Initia testnet is "initiation-2", not "initia-2". This is properly configured in both initia and culinaris chain configurations.
src/schema/registry.ts (6)
Learnt from: ALPAC-4
PR: initia-labs/initia-registry#274
File: _packages/types/src/zods/Profile.ts:12-17
Timestamp: 2025-02-06T07:15:46.189Z
Learning: The TypeScript types and Zod schemas in `@initia/initia-registry-types` package are auto-generated from JSON Schema files in the root directory. Modifications should be made to the schema files rather than the generated code.
Learnt from: ALPAC-4
PR: initia-labs/initia-registry#274
File: _packages/types/src/zods/Profile.ts:38-43
Timestamp: 2025-02-06T07:15:49.671Z
Learning: The TypeScript types and Zod schemas in `_packages/types/src/types/` and `_packages/types/src/zods/` are auto-generated from JSON Schema files in the root directory using json-schema-to-typescript and json-schema-to-zod libraries. Changes should be made to the source schema files, not the generated code.
Learnt from: joon9823
PR: initia-labs/initia.js#81
File: src/core/Msg.ts:518-521
Timestamp: 2024-10-08T18:48:55.677Z
Learning: In `src/core/Msg.ts`, within the `fromAmino` function, the type identifiers for `MsgUpdateIbcPermAdmin` and `MsgUpdatePermissionedRelayers` should use the prefix `'ibc-perm/'` as the valid identifier.
Learnt from: joon9823
PR: initia-labs/initia.js#81
File: src/core/Msg.ts:518-521
Timestamp: 2024-10-07T09:09:55.619Z
Learning: In `src/core/Msg.ts`, within the `fromAmino` function, the type identifiers for `MsgUpdateIbcPermAdmin` and `MsgUpdatePermissionedRelayers` should use the prefix `'ibc-perm/'` as the valid identifier.
Learnt from: ALPAC-4
PR: initia-labs/initia-registry#245
File: testnets/culinaris/chain.json:80-80
Timestamp: 2025-01-13T16:59:09.410Z
Learning: In chain.json files, the `op_bridge_id` field in the metadata section should be a string type, not an integer, as it represents the OPinit bridge identifier used for L1-L2 asset transfers.
Learnt from: evilpeach
PR: initia-labs/tx-decoder#28
File: src/metadata-resolver.ts:27-32
Timestamp: 2025-07-03T01:32:16.425Z
Learning: In the tx-decoder project, Zod is used for data validation at the input layer, which means direct property access is safe in functions like `resolveMetadata` since the data structure is already validated. Optional chaining is not needed in such cases.
src/tests/ibc/send-nft.test.ts (6)
Learnt from: joon9823
PR: initia-labs/initia.js#81
File: src/core/Msg.ts:518-521
Timestamp: 2024-10-07T09:09:55.619Z
Learning: In `src/core/Msg.ts`, within the `fromAmino` function, the type identifiers for `MsgUpdateIbcPermAdmin` and `MsgUpdatePermissionedRelayers` should use the prefix `'ibc-perm/'` as the valid identifier.
Learnt from: joon9823
PR: initia-labs/initia.js#81
File: src/core/Msg.ts:518-521
Timestamp: 2024-10-08T18:48:55.677Z
Learning: In `src/core/Msg.ts`, within the `fromAmino` function, the type identifiers for `MsgUpdateIbcPermAdmin` and `MsgUpdatePermissionedRelayers` should use the prefix `'ibc-perm/'` as the valid identifier.
Learnt from: joon9823
PR: initia-labs/initia.js#86
File: src/client/rest/api/IbcAPI.spec.ts:4-4
Timestamp: 2024-10-18T02:40:07.439Z
Learning: In `src/client/rest/api/IbcAPI.spec.ts`, the REST endpoint `https://rest.devnet.initia.xyz/` is acceptable even if it returns a 501 Not Implemented status code.
Learnt from: ALPAC-4
PR: initia-labs/initia-registry#245
File: testnets/culinaris/chain.json:80-80
Timestamp: 2025-01-13T16:59:09.410Z
Learning: In chain.json files, the `op_bridge_id` field in the metadata section should be a string type, not an integer, as it represents the OPinit bridge identifier used for L1-L2 asset transfers.
Learnt from: ALPAC-4
PR: initia-labs/initia-registry#245
File: testnets/initia/chain.json:295-306
Timestamp: 2025-01-13T16:25:34.966Z
Learning: The correct chain ID for the Initia testnet is "initiation-2", not "initia-2". This is properly configured in both initia and culinaris chain configurations.
Learnt from: ALPAC-4
PR: initia-labs/rapid-relayer#20
File: src/db/controller/client.ts:54-66
Timestamp: 2024-12-17T07:59:34.765Z
Learning: In `src/db/controller/client.ts`, `consensusHeights` must exist and follow the `number-number` format as per the IBC-Go specification. If it doesn't exist or the format is incorrect, the process should throw an error and terminate.
src/tests/fixtures/ibc/receive-ft.fixture.ts (3)
Learnt from: joon9823
PR: initia-labs/initia.js#86
File: src/client/rest/api/IbcAPI.spec.ts:4-4
Timestamp: 2024-10-18T02:40:07.439Z
Learning: In `src/client/rest/api/IbcAPI.spec.ts`, the REST endpoint `https://rest.devnet.initia.xyz/` is acceptable even if it returns a 501 Not Implemented status code.
Learnt from: joon9823
PR: initia-labs/initia.js#81
File: src/core/Msg.ts:518-521
Timestamp: 2024-10-08T18:48:55.677Z
Learning: In `src/core/Msg.ts`, within the `fromAmino` function, the type identifiers for `MsgUpdateIbcPermAdmin` and `MsgUpdatePermissionedRelayers` should use the prefix `'ibc-perm/'` as the valid identifier.
Learnt from: joon9823
PR: initia-labs/initia.js#81
File: src/core/Msg.ts:518-521
Timestamp: 2024-10-07T09:09:55.619Z
Learning: In `src/core/Msg.ts`, within the `fromAmino` function, the type identifiers for `MsgUpdateIbcPermAdmin` and `MsgUpdatePermissionedRelayers` should use the prefix `'ibc-perm/'` as the valid identifier.
src/tests/fixtures/ibc/send-nft.fixture.ts (1)
Learnt from: joon9823
PR: initia-labs/initia.js#86
File: src/client/rest/api/IbcAPI.spec.ts:4-4
Timestamp: 2024-10-18T02:40:07.439Z
Learning: In `src/client/rest/api/IbcAPI.spec.ts`, the REST endpoint `https://rest.devnet.initia.xyz/` is acceptable even if it returns a 501 Not Implemented status code.
src/tests/fixtures/ibc/send-ft.fixture.ts (3)
Learnt from: joon9823
PR: initia-labs/initia.js#86
File: src/client/rest/api/IbcAPI.spec.ts:4-4
Timestamp: 2024-10-18T02:40:07.439Z
Learning: In `src/client/rest/api/IbcAPI.spec.ts`, the REST endpoint `https://rest.devnet.initia.xyz/` is acceptable even if it returns a 501 Not Implemented status code.
Learnt from: joon9823
PR: initia-labs/initia.js#81
File: src/core/Msg.ts:518-521
Timestamp: 2024-10-08T18:48:55.677Z
Learning: In `src/core/Msg.ts`, within the `fromAmino` function, the type identifiers for `MsgUpdateIbcPermAdmin` and `MsgUpdatePermissionedRelayers` should use the prefix `'ibc-perm/'` as the valid identifier.
Learnt from: joon9823
PR: initia-labs/initia.js#81
File: src/core/Msg.ts:518-521
Timestamp: 2024-10-07T09:09:55.619Z
Learning: In `src/core/Msg.ts`, within the `fromAmino` function, the type identifiers for `MsgUpdateIbcPermAdmin` and `MsgUpdatePermissionedRelayers` should use the prefix `'ibc-perm/'` as the valid identifier.
src/tests/ibc/transfer.test.ts (5)
Learnt from: joon9823
PR: initia-labs/initia.js#81
File: src/core/Msg.ts:518-521
Timestamp: 2024-10-08T18:48:55.677Z
Learning: In `src/core/Msg.ts`, within the `fromAmino` function, the type identifiers for `MsgUpdateIbcPermAdmin` and `MsgUpdatePermissionedRelayers` should use the prefix `'ibc-perm/'` as the valid identifier.
Learnt from: joon9823
PR: initia-labs/initia.js#81
File: src/core/Msg.ts:518-521
Timestamp: 2024-10-07T09:09:55.619Z
Learning: In `src/core/Msg.ts`, within the `fromAmino` function, the type identifiers for `MsgUpdateIbcPermAdmin` and `MsgUpdatePermissionedRelayers` should use the prefix `'ibc-perm/'` as the valid identifier.
Learnt from: joon9823
PR: initia-labs/initia.js#86
File: src/client/rest/api/IbcAPI.spec.ts:4-4
Timestamp: 2024-10-18T02:40:07.439Z
Learning: In `src/client/rest/api/IbcAPI.spec.ts`, the REST endpoint `https://rest.devnet.initia.xyz/` is acceptable even if it returns a 501 Not Implemented status code.
Learnt from: ALPAC-4
PR: initia-labs/initia-registry#245
File: testnets/culinaris/chain.json:80-80
Timestamp: 2025-01-13T16:59:09.410Z
Learning: In chain.json files, the `op_bridge_id` field in the metadata section should be a string type, not an integer, as it represents the OPinit bridge identifier used for L1-L2 asset transfers.
Learnt from: ALPAC-4
PR: initia-labs/rapid-relayer#20
File: src/db/controller/client.ts:54-66
Timestamp: 2024-12-17T07:59:34.765Z
Learning: In `src/db/controller/client.ts`, `consensusHeights` must exist and follow the `number-number` format as per the IBC-Go specification. If it doesn't exist or the format is incorrect, the process should throw an error and terminate.
src/decoders/ibc/nft.ts (3)
Learnt from: joon9823
PR: initia-labs/initia.js#81
File: src/core/Msg.ts:518-521
Timestamp: 2024-10-08T18:48:55.677Z
Learning: In `src/core/Msg.ts`, within the `fromAmino` function, the type identifiers for `MsgUpdateIbcPermAdmin` and `MsgUpdatePermissionedRelayers` should use the prefix `'ibc-perm/'` as the valid identifier.
Learnt from: joon9823
PR: initia-labs/initia.js#81
File: src/core/Msg.ts:518-521
Timestamp: 2024-10-07T09:09:55.619Z
Learning: In `src/core/Msg.ts`, within the `fromAmino` function, the type identifiers for `MsgUpdateIbcPermAdmin` and `MsgUpdatePermissionedRelayers` should use the prefix `'ibc-perm/'` as the valid identifier.
Learnt from: ALPAC-4
PR: initia-labs/rapid-relayer#20
File: src/workers/chain.ts:148-163
Timestamp: 2024-12-17T07:46:51.776Z
Learning: Error handling for `feedUpdateClientEvent` is already implemented at line 129 in `src/workers/chain.ts` within the `feedEvents` method of the `SyncWorker` class.
src/tests/ibc/receive-nft.test.ts (4)
Learnt from: joon9823
PR: initia-labs/initia.js#81
File: src/core/Msg.ts:518-521
Timestamp: 2024-10-08T18:48:55.677Z
Learning: In `src/core/Msg.ts`, within the `fromAmino` function, the type identifiers for `MsgUpdateIbcPermAdmin` and `MsgUpdatePermissionedRelayers` should use the prefix `'ibc-perm/'` as the valid identifier.
Learnt from: joon9823
PR: initia-labs/initia.js#81
File: src/core/Msg.ts:518-521
Timestamp: 2024-10-07T09:09:55.619Z
Learning: In `src/core/Msg.ts`, within the `fromAmino` function, the type identifiers for `MsgUpdateIbcPermAdmin` and `MsgUpdatePermissionedRelayers` should use the prefix `'ibc-perm/'` as the valid identifier.
Learnt from: joon9823
PR: initia-labs/initia.js#86
File: src/client/rest/api/IbcAPI.spec.ts:4-4
Timestamp: 2024-10-18T02:40:07.439Z
Learning: In `src/client/rest/api/IbcAPI.spec.ts`, the REST endpoint `https://rest.devnet.initia.xyz/` is acceptable even if it returns a 501 Not Implemented status code.
Learnt from: ALPAC-4
PR: initia-labs/initia-registry#245
File: testnets/culinaris/chain.json:80-80
Timestamp: 2025-01-13T16:59:09.410Z
Learning: In chain.json files, the `op_bridge_id` field in the metadata section should be a string type, not an integer, as it represents the OPinit bridge identifier used for L1-L2 asset transfers.
src/decoders/ibc/transfer.ts (2)
Learnt from: joon9823
PR: initia-labs/initia.js#81
File: src/core/Msg.ts:518-521
Timestamp: 2024-10-08T18:48:55.677Z
Learning: In `src/core/Msg.ts`, within the `fromAmino` function, the type identifiers for `MsgUpdateIbcPermAdmin` and `MsgUpdatePermissionedRelayers` should use the prefix `'ibc-perm/'` as the valid identifier.
Learnt from: joon9823
PR: initia-labs/initia.js#81
File: src/core/Msg.ts:518-521
Timestamp: 2024-10-07T09:09:55.619Z
Learning: In `src/core/Msg.ts`, within the `fromAmino` function, the type identifiers for `MsgUpdateIbcPermAdmin` and `MsgUpdatePermissionedRelayers` should use the prefix `'ibc-perm/'` as the valid identifier.
src/interfaces/decoded-messages.ts (3)
Learnt from: joon9823
PR: initia-labs/initia.js#81
File: src/core/Msg.ts:518-521
Timestamp: 2024-10-08T18:48:55.677Z
Learning: In `src/core/Msg.ts`, within the `fromAmino` function, the type identifiers for `MsgUpdateIbcPermAdmin` and `MsgUpdatePermissionedRelayers` should use the prefix `'ibc-perm/'` as the valid identifier.
Learnt from: joon9823
PR: initia-labs/initia.js#81
File: src/core/Msg.ts:518-521
Timestamp: 2024-10-07T09:09:55.619Z
Learning: In `src/core/Msg.ts`, within the `fromAmino` function, the type identifiers for `MsgUpdateIbcPermAdmin` and `MsgUpdatePermissionedRelayers` should use the prefix `'ibc-perm/'` as the valid identifier.
Learnt from: ALPAC-4
PR: initia-labs/initia-registry#245
File: testnets/culinaris/chain.json:80-80
Timestamp: 2025-01-13T16:59:09.410Z
Learning: In chain.json files, the `op_bridge_id` field in the metadata section should be a string type, not an integer, as it represents the OPinit bridge identifier used for L1-L2 asset transfers.
src/api.ts (3)
Learnt from: joon9823
PR: initia-labs/initia.js#81
File: src/core/Msg.ts:518-521
Timestamp: 2024-10-08T18:48:55.677Z
Learning: In `src/core/Msg.ts`, within the `fromAmino` function, the type identifiers for `MsgUpdateIbcPermAdmin` and `MsgUpdatePermissionedRelayers` should use the prefix `'ibc-perm/'` as the valid identifier.
Learnt from: joon9823
PR: initia-labs/initia.js#81
File: src/core/Msg.ts:518-521
Timestamp: 2024-10-07T09:09:55.619Z
Learning: In `src/core/Msg.ts`, within the `fromAmino` function, the type identifiers for `MsgUpdateIbcPermAdmin` and `MsgUpdatePermissionedRelayers` should use the prefix `'ibc-perm/'` as the valid identifier.
Learnt from: joon9823
PR: initia-labs/initia.js#86
File: src/client/rest/api/IbcAPI.spec.ts:4-4
Timestamp: 2024-10-18T02:40:07.439Z
Learning: In `src/client/rest/api/IbcAPI.spec.ts`, the REST endpoint `https://rest.devnet.initia.xyz/` is acceptable even if it returns a 501 Not Implemented status code.
src/tests/fixtures/ibc/receive-nft.fixture.ts (3)
Learnt from: joon9823
PR: initia-labs/initia.js#86
File: src/client/rest/api/IbcAPI.spec.ts:4-4
Timestamp: 2024-10-18T02:40:07.439Z
Learning: In `src/client/rest/api/IbcAPI.spec.ts`, the REST endpoint `https://rest.devnet.initia.xyz/` is acceptable even if it returns a 501 Not Implemented status code.
Learnt from: joon9823
PR: initia-labs/initia.js#81
File: src/core/Msg.ts:518-521
Timestamp: 2024-10-08T18:48:55.677Z
Learning: In `src/core/Msg.ts`, within the `fromAmino` function, the type identifiers for `MsgUpdateIbcPermAdmin` and `MsgUpdatePermissionedRelayers` should use the prefix `'ibc-perm/'` as the valid identifier.
Learnt from: joon9823
PR: initia-labs/initia.js#81
File: src/core/Msg.ts:518-521
Timestamp: 2024-10-07T09:09:55.619Z
Learning: In `src/core/Msg.ts`, within the `fromAmino` function, the type identifiers for `MsgUpdateIbcPermAdmin` and `MsgUpdatePermissionedRelayers` should use the prefix `'ibc-perm/'` as the valid identifier.
🧬 Code Graph Analysis (3)
src/tests/ibc/send-nft.test.ts (2)
src/tests/helpers/api.ts (2)
setupMockApi(12-19)mockedAxios(10-10)src/tests/fixtures/ibc/send-nft.fixture.ts (1)
mockApiResponsesForIbcSendNft(432-512)
src/decoders/ibc/transfer.ts (3)
src/schema/messages.ts (2)
Message(16-16)zMsgIbcTransfer(77-86)src/schema/transaction.ts (1)
Log(96-96)src/api.ts (1)
ApiClient(21-253)
src/api.ts (1)
src/schema/rest.ts (1)
zNodeInfo(3-7)
🔇 Additional comments (23)
src/schema/index.ts (1)
7-7: Barrel export looks goodRe-exporting the new REST schema makes it accessible to callers and keeps the index file in alphabetical order.
Nothing else to flag here.src/tests/fixtures/op-init/initiate-token-deposit.fixture.ts (1)
460-462: Emptyibc_channelsarray is fine but double-check schema expectationsIf the updated
zMetadataschema now requires objects insideibc_channels, an empty array will validate but downstream logic that assumes at least one entry might break.
Please verify tests that iterate overibc_channelshandle the empty case gracefully.src/tests/fixtures/op-init/finalize-token-withdrawal.fixture.ts (1)
468-470: Mirror the same verification for this fixtureSame note as above—confirm that consumer code tolerates an empty
ibc_channelslist so tests remain representative of main-net data.src/tests/fixtures/ibc/receive-ft.fixture.ts (1)
1798-1843: LGTM! Well-structured mock API responses for enhanced IBC testing.The new fixture properly supports the enhanced IBC data structure with detailed chain and channel information, enabling comprehensive testing of the new chain ID resolution features.
src/schema/registry.ts (2)
3-8: LGTM! Well-defined IBC channel schema.The schema properly captures all necessary IBC channel fields with appropriate string types.
11-11: LGTM! Proper integration of IBC channels into metadata schema.The addition of the required
ibc_channelsfield enhances the metadata structure to support the new IBC functionality.src/tests/ibc/send-nft.test.ts (3)
18-18: LGTM! Better test organization.Moving the mock API setup to
beforeEachimproves test consistency and follows best practices.
38-46: LGTM! Enhanced IBC data structure with clear source/destination separation.The new fields provide better clarity and completeness for IBC channel and chain information in the decoded message.
130-135: LGTM! Comprehensive validation of enhanced IBC channel information.The updated assertions properly verify all the new source and destination chain, channel, and port fields.
src/tests/ibc/receive-nft.test.ts (2)
48-55: LGTM! Enhanced IBC data structure for source token receive scenario.The updated expected data properly captures the source and destination chain/channel information for the IBC NFT receive flow.
121-129: LGTM! Enhanced IBC data structure for remote token receive scenario.The updated expected data properly handles the remote token scenario with WASM contract ports and different chain relationships, providing comprehensive test coverage.
src/tests/ibc/transfer.test.ts (3)
1-4: LGTM! Proper import organization for enhanced IBC testing.The addition of
mockApiResponsesForMsgIbcRecvPacketfrom the receive fixture properly separates concerns between send and receive test scenarios.
35-42: Field naming changes align with new IBC interface structure.The transition from verbose field names (e.g.,
destinationChannel) to abbreviated names (e.g.,dstChannel) and the addition of explicit chain IDs (srcChainId,dstChainId) properly reflects the enhanced IBC data structure mentioned in the PR objectives.
72-72: Proper separation of mock responses for different IBC scenarios.Using
mockApiResponsesForMsgIbcRecvPacketfor receive message tests ensures the mock data aligns with the specific requirements of each test case.src/tests/fixtures/ibc/send-ft.fixture.ts (2)
545-581: Comprehensive mock chain registry data for IBC testing.The mock
/chains.jsonresponse provides well-structured chain metadata with bidirectional IBC channel mappings. The inclusion of both chains ("interwoven-1" and "moo-1") with proper channel, port, and version information supports comprehensive testing of the new chain ID resolution functionality.
582-586: Proper node info mock response structure.The
/cosmos/base/tendermint/v1beta1/node_infomock response correctly provides the network identifier, enabling the newgetChainIdmethod to be tested effectively.src/tests/fixtures/ibc/send-nft.fixture.ts (1)
434-454: Appropriate NFT-specific mock data structure.The mock responses properly reflect NFT transfer requirements with the correct
nft-transferport andics721-1version identifier. The structure is consistent with the FT fixture while being tailored for NFT use cases.src/api.ts (1)
14-14: LGTM! Proper schema import for validation.The addition of
zNodeInfoimport supports the newgetChainIdmethod's response validation.src/tests/fixtures/ibc/receive-nft.fixture.ts (1)
1566-1593: LGTM! Mock data additions are well-structured.The new mock API endpoints provide the necessary chain metadata and node info for the enhanced IBC decoding logic. The IBC channel data structure correctly includes all required fields (chain_id, channel_id, port_id, version) for resolving counterparty chain IDs.
src/decoders/ibc/nft.ts (2)
52-76: Well-implemented chain ID resolution for NFT send decoder.The decoder correctly:
- Fetches the source chain ID from the current node
- Extracts destination port/channel from packet event attributes
- Resolves the destination chain ID using IBC channel metadata
- Includes comprehensive error handling with descriptive messages
Also applies to: 87-94
157-181: Consistent implementation for NFT receive decoder.The decoder correctly handles the receive packet flow:
- Destination chain ID is the current node's chain
- Source port/channel are extracted from packet event attributes
- Source chain ID is resolved using the counterparty lookup
- Error handling matches the send decoder pattern
Also applies to: 192-199
src/decoders/ibc/transfer.ts (1)
16-60: Fungible token decoders properly enhanced with chain ID resolution.The implementation follows the same robust pattern as the NFT decoders:
- Proper extraction of channel/port from packet events
- Correct chain ID resolution for both send and receive flows
- Consistent error handling with descriptive messages
- Updated data structures align with the new interface definitions
Also applies to: 68-110
src/interfaces/decoded-messages.ts (1)
38-68: Interface updates provide clearer and more complete IBC routing information.The consistent renaming and additions across all IBC message interfaces:
- Improves clarity with
src/dstprefixes instead ofsource/destination- Adds explicit chain IDs alongside ports and channels for complete routing context
- Maintains consistency across fungible token and NFT message types
Also applies to: 187-231
Summary by CodeRabbit
New Features
Bug Fixes
Tests
Documentation